package com.shxt.service.impl;

import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.shxt.mapper.UserMapper;
import com.shxt.model.Role;
import com.shxt.model.User;
import com.shxt.service.UserService;
@Service
public class UserServiceImpl implements UserService {
	@Autowired
	private UserMapper userMapper;
	@Override
	public int delete( Integer user_id ) {
		// TODO Auto-generated method stub
		return this.userMapper.delete(user_id);
	}

	@Override
	public int add( User user ) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public User load( Integer user_id ) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int update( User user ) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Map<String, Object> login( User user ) {
		//获取mapper中的数据
		User user2 =this.userMapper.login(user);
		//装返回信息
		Map<String , Object> map = new HashMap<String , Object>();
		if(user2!=null){
			if(user2.getFk_role_id()==0){
				map.put("message" ,"你未拥有权限，不能登录系统");
			}else{
				map.put("user" , user2);
			}
		}else{
			map.put("message","账号密码不匹配");
		}
		return map;
	}

	@Override
	public int mdiUserByRole_Id( Role role ) {
		// TODO Auto-generated method stub
		return this.userMapper.mdiUserByRole_Id(role);
	}

}
